﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using SuppKids.Core.Domain;

namespace SuppKids.Core.Repository
{
    public interface IRepository<T> : IDisposable where T : Entity
	{
		IQueryable<T> GetQuery();

		IEnumerable<T> GetAll(params Expression<Func<T, object>>[] includes);

		IEnumerable<T> GetAll(Expression<Func<T, bool>> whereCondition, params Expression<Func<T, object>>[] includes);

		IEnumerable<T> GetPage<TKey>(int pageNumber, int pageSize, out int totalCount, Expression<Func<T, bool>> whereCondition, Expression<Func<T, TKey>> orderBy, bool orderByAscending = true, params Expression<Func<T, object>>[] includes);

		IEnumerable<T> GetPage<TKey>(int pageNumber, int pageSize, out int totalCount, Expression<Func<T, bool>> whereCondition, Func<IQueryable<T>, IQueryable<T>> orderByClause = null, params Expression<Func<T, object>>[] includes);

		IEnumerable<T> GetPageOrderedById(int pageNumber, int pageSize, out int totalCount);

		T SingleOrDefault(Expression<Func<T, bool>> predicate, params Expression<Func<T, object>>[] includes);

		T FirstOrDefault(Expression<Func<T, bool>> predicate, params Expression<Func<T, object>>[] includes);

		T FirstOrDefault(int id);

		void Add(T entity);

		void Delete(T entity);

		void Attach(T entity);

		void SaveChanges();

		void Update(T entity);
	}
}